<?php $this->import('Header') ?>
	<div class="row-fluid">
		<div class="btn-toolbar">
			<a href="/Article/Add" class="btn btn-primary"><i class="icon-plus"></i> 添加文章</a>
		</div>
		<form id="js-pager" >
			<input type="hidden" value="1" name="page" />
			<select defaultId="<?php echo $categoryId ?>" name="categoryId" id="js-category">
			</select>
			<label></label>
			<button type="submit" class="btn">搜索</button>
		</form>
		<div class="well">
			<div class="tab-content">
				<table class="table">
					<tr>
						<td>名称</td>
						<td>分类</td>
						<td>添加时间</td>
						<td>修改时间</td>
						<td style="width: 160px;">操作</td>
					</tr>
					<?php foreach ($list as $arr) { ?>
					<tr>
						<td><?php echo $arr['Title'] ?></td>
						<td><?php echo $arr['CategoryName'] ?></td>
						<td><?php echo date('Y-m-d H:i:s', $arr['CreateTime']) ?></td>
						<td><?php echo date('Y-m-d H:i:s', $arr['UpdateTime']) ?></td>
						<td>
							<a href="javascript:;" onclick="del(<?php echo $arr['ArticleId'] ?>)" class="btn">删除</a>
							<a href="/Article/Add?id=<?php echo $arr['ArticleId'] ?>" class="btn">修改</a>
						</td>
					</tr>
					<?php } ?>
				</table>
				<?php \Controller\UC\Pager::instance()->run(array('pager' => $pager)) ?>
			</div>
		</div>
	</div>
<?php $this->import('Footer') ?>
<script>
function del(id) {
	if (confirm('确定要删除这篇文章吗？')) {
		$.ajax({
			url: '/Ajax/Article/Del',
			data: {id:id},
			dataType: 'json',
			success: function(data) {
				if (data.error) {
					alert(data.data);
				} else {
					window.location.reload();
				}
			}
		});
	}
}
$('#js-category').category({
	pid:<?php echo !empty($category['Pid']) ? $category['Pid'] : 0 ?>,
	data: <?php echo json_encode($all) ?>,
	selectAll: true
});
</script>